package org.jeecg.modules.platform.api;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.constant.ServiceNameConstants;
import org.jeecg.common.system.api.entity.SysPermission;
import org.jeecg.modules.platform.fallback.PlatformOrganizationPermissionFallback;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
@FeignClient(contextId = "SysPlatformOrgPermissionApi", value = ServiceNameConstants.SERVICE_SYSTEM, path = ServiceNameConstants.PATH_ORGANIZATION_PERMISSION, fallback = PlatformOrganizationPermissionFallback.class)
@ConditionalOnMissingClass("org.jeecg.modules.platform.organization.controller.CyPlatformOrganizationPermissionController")
public interface PlatformOrganizationPermissionApi {

    @GetMapping("listModules")
    @ApiOperation("查询模块")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "child", value = "是否查询子模块", defaultValue = "false", required = false)
    })
    List<SysPermission> listModules(@RequestParam(name = "child",defaultValue = "false", required = false) Boolean child);


    @GetMapping("listOrgPermission")
    @ApiOperation("获取组织拥有的模块的全部权限")
    List<SysPermission> listOrgPermission(@RequestParam String orgId);

    @GetMapping("listModuleByOrg")
    @ApiOperation("查询当前有权限的模块[未过期的]")
    List<String> listModuleByOrg(@RequestParam(name = "orgId") String orgId);
}
